(function(){
  Ext.onReady(function(){
     Ext.QuickTips.init();
	 var loginform= Ext.create('Ext.form.Panel',{
	    id:'one',
	    frame:true,
	    title:'登陆框',
	    bodyPadding:5,
	    width:320,
	    height:200,
	    renderTo: Ext.getBody(),
	    layout:'anchor',
	    	defaults:{ 
	         anchor:'100%',
	         
	         labelWidth:70,
		   	  width:200,
		   	  labelAlign:'left'
	   	},
	   	defaultType:'textfield',
	 	 items:[{
	   	 
	   	 fieldLabel:'账号',
         name:'name'
        },
	   	 {fieldLabel:'密码',
          name:'password'
         
          
      }],
	   	
	   	  buttons:[{ text:'登陆',
	   	  width:70,
	   	  height:20,
	   	  
			   	 handler:function(){
			   	 	if(loginform.getForm().isValid()){
			   	        loginform.getForm().submit({
			   	  	//params:loginform.getValues('name'),
			   	     method : 'POST',
			   	     url : 'login.action',
			   	     timeout:'100',
			   	     success:function(form,action){
			   	     	Ext.getCmp('one').setVisible(false);
			   	     	
			   	    var num= action.result.total;
			   	    if(num==0){
			   	    	 document.location="main.jsp";
			   	    }else{ 
			   	     //this.getEl().mask('请稍等...');
			   	     	 Ext.MessageBox.confirm('温馨提示', '您有'+num+'个新任务需要完成，现在去看看吗？', function(btn) {
										if (btn == 'yes') {
										 document.location="main.jsp?detailid=myJobView";
											
										}else{ document.location="main.jsp";}
										
										});
			   	    }
		
			   	     },
			   	     failure:function(){
			   	     	
			   	     Ext.Msg.alert('消息ʾ', '提示: 密码或用户名错误');
			   	     	}
			   	    })
			   	 
			   
			   	 	}
			   	  
			   	  }
	   	  
	   	  },{ text:'重置',
	   	  width:70,
	   	  height:20,
	   	  handler:function(){
	   	   this.up('form').getForm().reset();
	   	  
	   	  }}
	   	  ]
	 	
	 	
	 	
	 })
	  	
  
  
  
  
  
  });
	
	//添加键盘事件
	Ext.create('Ext.util.KeyMap', {
         target: loginform,
          key: Ext.EventObject.F2,
          fn: function (key, ev) {
              alert('添加B');
 
             ev.stopEvent();
 
              return false;
          },
          autoEl: {
                 tag: 'div',
                tabindex: 0
           }
      });
 
      Ext.get('one').focus();
	
	
	
	
})()